<?php

/**
 * @author Martin Pernica
 * @copyright 2009
 */

echo "<br />\n<h2>".Lang::getBack('com_user', 'fields')."</h2>\n";

echo "<a href=\"/administrator/index.php?p=components&name=user&a=fields-new\"><img src=\"../libs/icons/add.png\" /> ".Lang::getBack('com_user', 'fields_new')."</a>";

$fields = $db->query("SELECT * FROM {prefix}fields ORDER BY id;");
$cats = $db->query("SELECT * FROM {prefix}fields_cats ORDER BY id;");

echo "<table>\n";
echo "<tr><th>".Lang::getBack('com_user', 'fields_desc')."</th><th>".Lang::getBack('com_user', 'fields_unique')."</th><th>".Lang::getBackGlobal('action')."</th></tr>\n";

while($data = $fields->fetch_array()){
	
	$action = '<a href="index.php?p=components&amp;name=user&amp;a=fields-edit&amp;id='.$data['id'].'"><img src="../libs/icons/style_edit.png" /></a> <a href="index.php?p=components&amp;name=user&amp;a=fields-delete&amp;id='.$data['id'].'"><img src="../libs/icons/delete.png" /></a>';
	
    $data['sql_name'] = str_replace('field_', '', $data['sql_name']);
    
	echo "<tr><td>".$data['desc']."</td><td>".$data['sql_name']."</td><td>".$action."</td></tr>\n";
}

echo "</table>\n<br />\n";

echo "<br />\n<h2>".Lang::getBack('com_user', 'fields_category')."</h2>\n";

echo "<a href=\"/administrator/index.php?p=components&name=user&a=fields-cat-new\"><img src=\"../libs/icons/add.png\" /> ".Lang::getBack('com_user', 'fields_category_new')."</a>";

echo "<table>\n";
echo "<tr><th>ID</th><th>".Lang::getBack('com_user', 'fields_category')."</th><th>".Lang::getBackGlobal('action')."</th></tr>\n";

while($data = $cats->fetch_array()){
		
	$action = '<a href="index.php?p=components&amp;name=user&amp;a=fields-cat-edit&amp;id='.$data['id'].'"><img src="../libs/icons/style_edit.png" /></a> <a href="index.php?p=components&amp;name=user&amp;a=fields-cat-delete&amp;id='.$data['id'].'"><img src="../libs/icons/delete.png" /></a>';
	
	echo "<tr><td>".$data['id']."</td><td>".$data['title']."</td><td>".$action."</td></tr>\n";
}

echo "</table>\n";

?>